package cn.wolfcode.crm.service.impl;

import cn.wolfcode.crm.domain.Carinfo;
import cn.wolfcode.crm.mapper.CarinfoMapper;
import cn.wolfcode.crm.query.CarInfoQueryObject;
import cn.wolfcode.crm.query.PageResult;
import cn.wolfcode.crm.service.ICarInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CarInfoServiceImpl implements ICarInfoService{
    @Autowired
    private CarinfoMapper carinfoMapper;

    public int deleteByPrimaryKey(Long id) {
        return carinfoMapper.deleteByPrimaryKey(id);
    }

    public int insert(Carinfo record) {
        return carinfoMapper.insert(record);
    }

    public Carinfo selectByPrimaryKey(Long id) {
        return carinfoMapper.selectByPrimaryKey(id);
    }

    public List<Carinfo> selectAll() {
        return carinfoMapper.selectAll();
    }

    public int updateByPrimaryKey(Carinfo record) {
        return carinfoMapper.updateByPrimaryKey(record);
    }

    //分页
    public PageResult query(CarInfoQueryObject qo){
        //查总数
        int total = carinfoMapper.queryForCount(qo);
        if(total==0){
            return new PageResult();
        }
        //查每页数据
        List<Carinfo> rows = carinfoMapper.queryForList(qo);

        return new PageResult(rows,total);
    }

}
